
import Mock from 'mockjs'

const orders = Mock.mock({
  'list|2': [{
    'id|+1': 1,
    order_number: /\d{10}/,
    price: '@natural(1000000, 100000000)',
    price_rmb: '@natural(100000, 10000000)',
    create_time: '@date(yyyy-MM-dd)',
    'remark|1': ['@ctitle(0, 140)', ''],
    'bankname|1': ['', '中国民生银行'],
    'bankcard|1': ['', '6223 3434 3232 343'],
    'address|1': ['', '@county(true)'],
    other_fee: '@natural(10001, 1000000)',
    lot_rate: 1.23,
    user_name: '@cname',
    user_num: '@natural(1000, 9999)',
    'type|+1': ['send', 'buy'],
    status: '@natural(-1, 1)',
    lotId: '@natural(1, 199)',
    lotName: '古美术',
    'goods|1-10': [{
      'id|+1': 1,
      number: '@natural(1000, 9999)',
      name: '@ctitle(6, 14)',
      final_price: '@natural(1000000, 100000000)',
      fee_rate: 0.15,
      fee: '@natural(10000, 1000000)',
      tax_rate: 0.2,
      tax: '@natural(10000, 1000000)',
      catafee: '@natural(10000, 1000000)',
      sum:  '@natural(1000000, 100000000)',
      postage: '@natural(0, 1000000)',
    }]
  }],
  total: 30
})

export default [
  {
    url: '/order/setTaxRate',
    type: 'post',
    response: config => {
      const { tax } = config.body
      return {
        code: 200,
        data: Number(tax),
        msg: '税率设置成功！'
      }
    }
  },
  {
    url: '/order/getTaxRate',
    type: 'get',
    response: config => {
      return {
        code: 200,
        data: 0.011
      }
    }
  },
  {
    url: '/order/getOrders',
    type: 'get',
    response: config => {
      return {
        code: 200,
        data: orders
      }
    }
  },
  {
    url: '/order/createOrder',
    type: 'post',
    response: config => {
      return {
        code: 200,
        data: '5603267852',
        msg: '订单创建成功！'
      }
    }
  },
  {
    url: '/order/updateOrder',
    type: 'post',
    response: config => {
      return {
        code: 200,
        msg: '订单更新成功！'
      }
    }
  }
]
